Skip to main content

mockseries.seasonality.daily_seasonality

DailySeasonality#

class DailySeasonality(PeriodSeasonality)

Realistic daily seasonality from a set of time/value constraints.

Finest granularity for constraints and generation is microseconds. The interpolation method is PCHIP.

Arguments:

  • time_value_constraints - A dict of {time: value} constraints. The curve will pass through these points. Pass time as a timedelta between 0:00:00 and 23:59:59.999999. For instance, {timedelta(hours=3): 4.2, timedelta(hours=18): 5}
  • utc_offset - The offset from UTC of the time. For instance, if you give constraints with GMT-8 times in mind, pass timedelta(hours=-8). Default behavior considers times are passed as UTC.
  • normalize - transform constraints to a multiplication factor for easy use in multiplicative interactions. Eg: [5, 10, 15] --> [0.5, 1, 1.5].

Examples:

from datetime import timedelta, datetime
from mockseries.seasonality import DailySeasonality
timeseries = DailySeasonality({timedelta(hours=0): 1.,timedelta(hours=12): 2,timedelta(hours=18): 3})
timeseries.preview_day(num_days=4)